Skip to content

P17: «In IDE öffnen ▾» – open the block as a copy in the IDE - #18

Merged
cedricvogel-leo merged 1 commit into
mainfrom
feature/open-in-ide
Oct 25, 2026
Merged

cedricvogel-leo merged 1 commit into
mainfrom
feature/open-in-ide

Conversation

@cedricvogel-leo

Copy link
Copy Markdown
Collaborator

Package P17: learners can hand in a solution without copying code.

What learners see. A new split button at the end of the button row:

  • «In IDE öffnen» opens the block's current code as a copy in the glpython IDE (https://glpython-edu.github.io/) in a new tab. Tooltip: «Öffnet eine Kopie in der IDE – Änderungen dort wirken nicht hierher zurück.»
  • ▾ → «IDE-Link kopieren» copies the same link and confirms with «Link kopiert ✓». Without a clipboard (not allowed, or no API) the link appears in a field, focused and selected, under «Link zum Kopieren:».
  • English via language: en: «Open in IDE», «Copy IDE link», «Link copied ✓».

The link. It is the IDE's share-link format: ?project= + lz-string-compressed {v: 1, name, mainFile, files}.

  • Multi-file blocks: all files (and URL libraries, so their imports work there), and the file chosen in ▶'s ▾ menu as mainFile.
  • Name: the project name is the slide's heading.

iPad Safari. The link is built and copied synchronously inside the tap's own handler (writeText, and window.open for the tab). That's why lz-string 1.5.0 (the IDE's version, SRI-pinned, from jsDelivr) is loaded once per page in advance. The button stays disabled until it has loaded.

Length limit. GitHub Pages answers 414 above 8192 characters of path and query. That's a program of roughly 5,000–30,000 characters, depending on how well it compresses. A longer link carries the project in #project= instead, which isn't sent to the server. This needs glpython-edu/glpython-edu.github.io#14, which teaches the IDE to read the fragment. Merge that first. Links that fit keep ?project= and work with the IDE as deployed today.

features=. A new value, ide. It's on without features=, and hidden in visual blocks. The README and examples/profiles.md add it to erkunden and rezept, as the course will.

A bug found on the way. LiaScript replaced the @1 in …/lz-string@1.5.0/… with the macro's argument (eval), so the script URL became lz-stringeval.5.0. The URL now uses @, and check-macro.mjs now flags @<digit> glued to a word ([\w.\/-]@[0-9]). Real placeholders always stand on their own, and nothing else in the macro matches.

Tested in the hosted LiaScript player (this macro served locally), each link opened in a fresh browser profile and run:

Case Result
One block → «In IDE öffnen» new tab with the IDE
One block → «IDE-Link kopieren» «Link kopiert ✓», 250-char ?project= link, runs: Quadrat: 49
helfer.py + main.py + test.py, main.py chosen in ▶ ▾ all three files in the IDE, «Führt main.py aus», runs: Doppelt: 42
features=run,reset no IDE button
35,567-char program 9,225-char link with #project= (as ?project=: HTTP 414); runs with #14's IDE: Funktionen: 400 36
writeText rejects / no clipboard API link field shown, focused, fully selected
language: en English labels, tooltip and confirmation

node scripts/check-macro.mjs passes. iPad Safari itself I couldn't test (no device); the code follows its rule (copy and open inside the tap handler).

🤖 Generated with Claude Code

A split button in the button row (feature "ide", on by default) opens the
block's current program - every file, its libraries and the file that
runs - as a copy in the glpython IDE in a new tab, as an IDE share link.
Its ▾ menu copies that link («IDE-Link kopieren» → «Link kopiert ✓»), or
shows it in a field to copy by hand where the clipboard isn't available.
The link is built and copied within the tap's own handler, as iPad Safari
requires, with lz-string 1.5.0 (the IDE's) loaded once per page in
advance. A link longer than GitHub Pages accepts (8192 characters of path
and query) carries the project in the fragment.

check-macro.mjs now also flags "@<digit>" right after a letter, digit or
"-./": LiaScript replaces it with a macro argument even inside a URL, as it
did with ".../lz-string@1.5.0/...".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cedricvogel-leo
cedricvogel-leo merged commit c871165 into main Oct 25, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant